// 使用TS装饰器全局异常管理
const ErrorDecoratorFactory = (title: string = "默认值"): MethodDecorator => {
  return (...args: any[]) => {
    const [, , descriptor] = args
    const method = descriptor.value

    descriptor.value = () => {
      try {
        method()
      } catch (error: any) {
        console.log(`%c${title}`, 'color:green;font-size:18px;')
        console.log(`%c${error.message}`, 'color:red;font-size:16px;');

      }
    }
  }
}


class MyError2 {
  @ErrorDecoratorFactory()
  find() {
    throw new Error('出错了')
  }
}

new MyError2().find()
